<template>
  <el-dialog :title="$props.title" v-model="$data.dlg_show" width="80vw">
    <el-input type="textarea" :autosize="{minRows:4,maxRows:16}" :readonly="true"
              :modelValue="$data.content"></el-input>
  </el-dialog>
</template>
<script setup>
/**
 * Created by CodeGenerator at 2021-04-13 19:37:26
 */
defineOptions({
  name: "preview-txt",
  inheritAttrs: true,
});

//定义 vue2的this,当前组件
const $self = getCurrentInstance();

//定义 $attrs
const $attrs = useAttrs();

//定义data
const $data = reactive({
  dlg_show: true,
  content: ""
});

//定义属性
const $props = defineProps({
  value: {
    type: String, default() {
      return "";
    }
  }, title: {
    type: String, default() {
      return "内容";
    }
  }, format: {
    type: String, default() {
      return "json";
    }
  }
});


onMounted(() => {
  if ($props.format == "json") {
    $data.content = JSON.stringify(JSON.parse( $props.value), null, 4);
  } else {
    $data.content = $props.value;
  }
})


</script>
